<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class History_model extends MY_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getMyHistoryList($fields = ' * ',$per_page, $limit)
    {
    	
    	$limit = " limit {$per_page},{$limit}";

        $sql = "SELECT {$fields} FROM tr_history WHERE isDel=0  ORDER BY createtime DESC {$limit} ";

        $query = $this->db->query($sql);
        $result =$query->result_array();
        return $result;
    }


    public function getMyHistoryListCnt()
    {
        
        $sql = "SELECT id FROM tr_history WHERE isDel=0  ORDER BY createtime DESC";
        $query = $this->db->query($sql);
        return $query->num_rows();
    }

    public function createHistoryRecord($data = array())
    {
        $insertData = array(
            'createtime'=>time(),
            'AccountID'=>$_SESSION['userInfo']['AccountID'],
            'viewlink'=>$data['viewlink']
            );
        if(isset($data['title']))
        {
            $insertData['title'] = $data['title'];
        }
        $result = $this->db->insert("tr_history", $insertData);
        return $result;
    }


    
}

/* End of file Index_model.php */
/* Location: ./application/models/index_model.php */